﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "教师门户 - 网上成绩提交 - 成绩变更申请");
		
		sessionAdvice = getProperty("serviceFactory").getBean("sessionAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		datetimeAdvice = getProperty("serviceFactory").getBean("datetimeAdvice");
		
		teacherId = sessionAdvice.getAutherUserID();
		
		hashCode = event.getArg("Sign");
		taskId = event.getArg("TSK");
		taskType = event.getArg("TT");
		
		currentTab = event.getArg("TabID", "labApply");
		
		checked = false;

			if ( decrypt(hashCode, teacherId, "PBEWithMD5AndDES", "Hex") eq taskId ) {
				
				checked = true;
				
				/* 载入期末成绩提交任务 */
				sql = "	SELECT
							ttm.task_id,
							c.course_name,
							ttm.cidx,
							c.course_code,
							c.course_credit,
							i.institute_short,
							ttm.mark_done,
							ttm.mark_need,
							ttm.task_prog,
							c.mark_mode
						FROM	
							t_task_mark ttm
							INNER JOIN t_course c ON c.cid = ttm.cid
							INNER JOIN t_institute i ON i.institute_id = c.institute_id
						WHERE
							ttm.task_id = :taskId ";

				queryObj = new Query(datasource = application.dnsSlave);
				
				queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
				
				rs_task = queryObj.execute(sql=sql).getResult();
				
				/* 载入教师信息 */
				sql = "	SELECT
							tch.tch_id,
							tch.tch_name
						FROM
							t_teacher tch
						WHERE
							tch.tch_id = :teacherId ";
							
				queryObj = new Query(datasource = application.dnsSlave);
				
				queryObj.addParam(name="teacherId", value=teacherId, cfsqltype="cf_sql_varchar");
				
				rs_teacher = queryObj.execute(sql=sql).getResult();
				
				
				/* 检查有未审批的申请记录 */
				sql = "	SELECT
							ttmu.date_created,tch.tch_name
						FROM
							t_task_mark_unlock ttmu
							INNER JOIN t_teacher tch ON tch.tch_id = ttmu.sign_user_id
						WHERE
							ttmu.task_id = :taskId 
							AND
							ttmu.task_type = :taskType 
							AND
							ttmu.sign_status = 'W'";
							
				queryObj = new Query(datasource = application.dnsSlave);
				
				queryObj.addParam(name="taskId", value=taskId, cfsqltype="cf_sql_varchar");
				queryObj.addParam(name="taskType", value=taskType, cfsqltype="cf_sql_char");
				
				rs_check = queryObj.execute(sql=sql).getResult();
				
			}

		
	</cfscript>
</cfsilent>

<cfif checked >
		
		<div id="headArea">
			<div class="uiHeader uiHeaderWithImage ptm">
				<div class="clearfix uiHeaderTop">
					<div class="uiHeaderActions rfloat">
						<a class="uiButton" href="<cfoutput>#buildURL('taskMark')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">课程考核成绩</span></a>
					</div>
					<div>
						<h2 class="uiHeaderTitle">
							<i class="uiHeaderImage img icon16x16 card"></i>课程成绩更正申请
						</h2>
					</div>
				</div>
			</div>
		</div>
		
		<div class="UIElement">
			<ul class="senateFirstPage">
				<li>
					<div class="clearfix" id="summary">
						
						<div class="UItab">
							<div class="tabLables">
								<span <cfif currentTab eq "labApply">class="active"</cfif> id="labApply" tabTarget="Apply">申请解锁成绩任务</span>
							</div>
						</div>
						<script language="javascript" type="text/javascript">
							//<![CDATA[
							<!--
							$(document).ready(function() {
						
								/* init Tab */
								$("div.tabContent").hide();
								$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
								$("div.tabLables > span").click(function(){
									var $targetID = $(this).attr("tabTarget");
							
									$("div.tabLables span").removeClass("active");
									$(this).addClass("active");
							
									$("div.tabContent").not('[id="' + $targetID + '"]').hide();
									$("div.tabContent#" + $targetID).show();
								});
						
							});
							// -->
							//]]>
						</script>
						
						<div id="Apply" class="tabContent">
							
							<table class="UIEditable">
								<thead>
									<tr>
										<td>课程</td>
										<td width="50">课序号</td>
										<td width="90">课程号</td>
										<td width="40">学分</td>
										<td width="50">部门</td>
										<td width="60">提交进度</td>
										<td width="60">计分模式</td>
										<td width="60">状态</td>
									</tr>
								</thead>
								<tbody>
									<tr class="editRows">
										<td><cfoutput>#rs_task.course_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#rs_task.cidx#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#rs_task.course_code#</cfoutput></span></td>
										<td><span class="numeric"><cfoutput>#numberFormat( rs_task.course_credit, '_.__')#</cfoutput></span></td>
										<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_task.mark_done#</cfoutput> / <cfoutput>#rs_task.mark_need#</cfoutput></span></td>
										<td><cfoutput>#dictAdvice.getMarkModeName( rs_task.mark_mode )#</cfoutput></td>
										<td><cfoutput>#dictAdvice.getTaskMarkStat( rs_task.task_prog )#</cfoutput></td>
									</tr>
								</tbody>
							</table>
							
                            	<cfif rs_check.recordCount eq 0>
							
								<form id="applyCreate" onSubmit="javascript:return processVerfiyForm('applyCreate');" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('taskMarkUnlockSignDo')#</cfoutput>">
								
									<input name="TaskID" type="hidden" value="<cfoutput>#taskId#</cfoutput>"/>
									<input name="TaskType" type="hidden" value="<cfoutput>#taskType#</cfoutput>"/>
									<input name="TeacherID" type="hidden" value="<cfoutput>#teacherId#</cfoutput>"/>
								
									<div class="label">
										<span class="req">*</span><b>更正情况说明</b>
										<textarea id="ChangeReason" name="ChangeReason" verification="required"><cfoutput>#rs_task.course_name#</cfoutput> 在成绩正式提交后发现下面错误:<cfoutput>#chr(10)##chr(10)##chr(10)##chr(10)##chr(10)#</cfoutput></textarea>
										<p class="notice">请根据实际情况描述已提交成绩任务的更正原因, 并由教师本人对受影响的学生进行成绩更正解释</p>
									</div>
						
									<hr/>
						
									<div class="lable">
										<input class="button" type="submit" value="提交" />
										<input class="button1" type="reset" value="重设表单" />
									</div>
								
								</form>
							
								<cfelse>
									
									<div class="systemNotice">
										<h3>请耐心等待</h3>
										<p class="mln">
											此项教学任务在 <em><cfoutput>#datetimeAdvice.formatDateTimeString(rs_check.date_created)#</cfoutput></em>  
											由 <cfoutput>#rs_check.tch_name#</cfoutput> 申请进行成绩更正, 尚未获正式批复, 请不要重复提交更正申请.
										</p>
									</div>
									
							</cfif>
							
						</div>
						
					</div>
				</li>
			</ul>
		</div>

	<cfelse>
		
		<div id="headArea">
			<div class="uiHeader uiHeaderWithImage ptm">
				<div class="clearfix uiHeaderTop">
					<div class="uiHeaderActions rfloat">
						<a class="uiButton" href="<cfoutput>#buildURL('taskMark')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">课程考核成绩</span></a>
					</div>
					<div>
						<h2 class="uiHeaderTitle">
							<i class="uiHeaderImage img icon16x16 info"></i>身份验证失败
						</h2>
					</div>
				</div>
			</div>
		</div>
		
		<div class="UIElement">
			<ul class="senateFirstPage">
				<li>
					<div class="clearfix" id="summary">
						
						<div class="systemNotice">
							<h3><span class="img icon16x16 message"></span>错误的参数</h3>
							<p>请关闭浏览器重新登录 或 检查您是否使用了正确访问方式</p>
						</div>
						
					</div>
				</li>
			</ul>
		</div>
</cfif>
